//企业职位详情
import React, { Component } from 'react'
import {
    View,
} from 'react-native';

import { Sel_Pos_ComAction } from '../../../actions/postion_c'
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import Cdetailpos_top from './cdetailpos_top'
import Cdetailpos_body from './cdetailpos_body'

class Cdetailpos_all extends Component {


    // 初始化模拟数据
    constructor(props) {
        super(props);
    }

    //加载后渲染页面
    componentDidMount() {
        const { actions } = this.props;
        actions.Sel_Pos_ComAction({ postionId: this.props.navigation.state.params.postionId }); //初始化查询
    }

    render() {
        const { xzPostion } = this.props.xzPostion.data;
        return (
            <View style={{ backgroundColor: "#f6f6f6", flex: 1 }}>
                <Cdetailpos_top navigation={this.props.navigation} />
                <Cdetailpos_body
                    xzPostion={xzPostion}
                    company={xzPostion.company}
                    navigation={this.props.navigation} />
            </View>
        )
    }
}

//组合action
var actions = {
    Sel_Pos_ComAction,
}
//连接state到props
const mapStateToProps = state => {
    return {
        xzPostion: state.Sel_Pos_ComReducer             //自己的reducers
    }
}
//连接action
const mapDispatchToProps = (dispatch) => {
    return {
        actions: bindActionCreators(actions, dispatch)
    }
}
//导出组合好的组件(组合后状态改变重新渲染组合组件的页面)
export default connect(
    mapStateToProps, mapDispatchToProps
)(Cdetailpos_all);